﻿using AnlianCommon.API.Commands.CommonRegion;
using AnlianCommon.Common.DTO;
using AnlianCommon.Enum;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace AnlianCommon.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class RegionsController : ControllerBase
    {
        private readonly IMediator _mediator;

        public RegionsController(IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 市
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> CityQuerys(CityQueryCommand request, CancellationToken cancellationToken)
        {
            var result = await _mediator.Send(request);
            return result;
        }
        /// <summary>
        /// 区县
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> CountyQuerys(CountyQueryCommand request, CancellationToken cancellationToken)
        {
            var result =await _mediator.Send(request);
            return result;
        }
        /// <summary>
        /// 省
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> ProvinceQuerys(ProvinceQueryCommand request, CancellationToken cancellationToken)
        {
            var result = await _mediator.Send(request);
            return result;
        }
    }
}
